std::basic_string::erase

From Cppreference

Jump to: navigation, search
​basic_string& erase(size_type index = 0, size_type count = npos);
(1)
​iterator erase( iterator position );
iterator erase( const_iterator position );
(2) (pre-C++0x version)
(C++0x version)

​iterator erase( iterator first, iterator last );
iterator erase( const_iterator first, const_iterator last );
(3) (pre-C++0x version)
(C++0x version)


Removes specified characters from the string.

1) Removes count characters starting at index.

2) Removes the character at pos.

3) Removes the character in the range [first; last).

Contents

Parameters

index - first character to remove
count - number of characters to remove
pos - iterator to the character to remove
first, last - range of the characters to remove

Return value

1) *this​

2-3) iterator following the last removed character.

Complexity

1) linear in count.

2) constant.

3) linear in distance between first and last.

See also

clear
clears the contents
(public member function)
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox
In other languages